Questions
Age effect - General Questions
source("load_libraries.R")
source("functions.R")
load("../results/dge/norm_counts.RData")
load("../results/dge/dge.RData")
load("../results/dge/dge_net.RData")
load("../results/dge/dge_layout.RData")
load("../results/dge/dge_net_connected_gene_colors.RData")
load("../results/dge/dge_net_pal2.RData")
module_nb = length(unique(connected_gene_colors))
pal2 = c(pal2, "white", "black")
# Comparison between the ages (after controlling for type and gender)
global_52w_8w = results(dge, contrast= c(0,0,0,0,1,0,1/2,0,0,1/2), alpha=0.05, test="Wald")
global_104w_8w = results(dge, contrast= c(0,0,0,1,0,1/2,0,0,1/2,0), alpha=0.05, test="Wald")
global_104w_52w = results(dge, contrast= c(0,0,0,1,-1,1/2,-1/2,0,1/2,-1/2), alpha=0.05, test="Wald")
samples = c(
'SPF_8w_F_1_2','SPF_8w_F_3_2','SPF_8w_F_4_2','SPF_8w_F_5_2','GF_8w_F_1_2','GF_8w_F_2_2','GF_8w_F_3_2','GF_8w_F_4_2','GF_8w_F_5_2','SPF_8w_M_1_2','SPF_8w_M_2_2','SPF_8w_M_3_2','SPF_8w_M_4_2','GF_8w_M_1_2','GF_8w_M_2_2','GF_8w_M_3_2','GF_8w_M_4_2',
'SPF_52w_F_1_2','SPF_52w_F_2_2','SPF_52w_F_3_2','SPF_52w_F_4_2','SPF_52w_F_5_2','SPF_52w_F_6_2','GF_52w_F_1_2','GF_52w_F_2_2','GF_52w_F_3_2','GF_52w_F_4_2','GF_52w_F_5_2','GF_52w_F_6_2','SPF_52w_M_1_2','SPF_52w_M_2_2','SPF_52w_M_3_2','SPF_52w_M_4_2','SPF_52w_M_5_2','GF_52w_M_1_2','GF_52w_M_2_2','GF_52w_M_3_2','GF_52w_M_4_2',
'SPF_104w_F_1_2','SPF_104w_F_2_2','SPF_104w_F_3_2','GF_104w_F_1_2','GF_104w_F_2_2','GF_104w_F_3_2','SPF_104w_M_1_2','SPF_104w_M_2_2','SPF_104w_M_3_2','SPF_104w_M_4_2','SPF_104w_M_5_2','SPF_104w_M_6_2','SPF_104w_M_7_2','SPF_104w_M_8_2','SPF_104w_M_9_2','SPF_104w_M_10_2','SPF_104w_M_11_2','SPF_104w_M_12_2','SPF_104w_M_13_2','SPF_104w_M_14_2','GF_104w_M_1_2','GF_104w_M_2_2')
annot = as.data.frame(colData(dge)[, c("age", "gender", "type")])
to_comp = c("52w VS 8w", "104w VS 8w", "104w VS 52w")
global_stats = matrix(0, nrow=3, ncol=3)
rownames(global_stats) = to_comp
colnames(global_stats) = c("Wald padj < 0.05", "LFC > 0 (Wald padj < 0.05)", "LFC < 0 (Wald padj < 0.05)")
global_stats[1,] = get_stats_padj(global_52w_8w)
global_stats[2,] = get_stats_padj(global_104w_8w)
global_stats[3,] = get_stats_padj(global_104w_52w)
global_stats
plot_stat_mat(global_stats)
age_data = list(global_52w_8w, global_104w_8w, global_104w_52w)
names(age_data) = to_comp
age_deg = extract_diff_expr_genes(age_data, "age-effect/age/")
Genes that are differentially expressed in 52W vs 8W with abs(FC) > 2
# 52w != 8w with abs(FC) > 2
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,1])>1),1])))
plot_count_heatmap(genes,samples, annot)
Genes that are differentially expressed in 104W vs 8W with abs(FC) > 2
# 104w != 8w with abs(FC) > 2
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,2])>1),2])))
plot_count_heatmap(genes,samples, annot)
Genes that are differentially expressed in 104W vs 52W with abs(FC) > 2
# 104w != 52w with abs(FC) > 2
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,3])>1),3])))
plot_count_heatmap(genes,samples, annot)
Differentially expressed genes
# Differentially expressed genes
upset(as.data.frame(age_deg$deg))
Differentially more expressed genes
# Differentially more expressed genes
upset(as.data.frame(age_deg$pos))
Differentially less expressed genes
# Differentially less expressed genes
upset(as.data.frame(age_deg$neg))
fc = age_deg$fc_deg[!is.na(age_deg$fc_deg[,1]) & !is.na(age_deg$fc_deg[,2]) & is.na(age_deg$fc_deg[,3]),c(1,2)]
#heatmap.2(fc, Colv = NA, scale="column", cexCol=0.5, symbreaks=T)
rep = get_repartition(fc)
colnames(rep) = c("52w > 8w & 104w > 8w", "52w > 8w & 104w < 8w", "52w < 8w & 104w > 8w", "52w < 8w & 104w < 8w")
rep
With abs(FC) > 1
# 52w != 8w and 104w != 8w and 104w == 52w with abs(FC) > 1
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,1])>0 & abs(age_deg$fc_deg[,2])>0 & is.na(age_deg$fc_deg[,3])),1])))
plot_count_heatmap(genes,samples, annot)
fc = age_deg$fc_deg[!is.na(age_deg$fc_deg[,1]) & is.na(age_deg$fc_deg[,2]) & !is.na(age_deg$fc_deg[,3]),c(1,3)]
#heatmap.2(fc, Colv = NA, scale="column", cexCol=0.5, symbreaks=T)
rep = get_repartition(fc)
colnames(rep) = c("52w > 8w & 104w > 52w", "52w > 8w & 104w < 52w", "52w < 8w & 104w > 52w", "52w < 8w & 104w < 52w")
rep
With abs(FC) > 1
# 52w != 8w and 104w == 8w and 104w != 52w with abs(FC) > 1
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,1])>0 & is.na(age_deg$fc_deg[,2]) & abs(age_deg$fc_deg[,3])>0),1])))
plot_count_heatmap(genes,samples, annot)
# Genes that are differentially expressed in 104W vs 8W and in 104W vs 52W (and not in 52w vs 8w)
fc = age_deg$fc_deg[is.na(age_deg$fc_deg[,1]) & !is.na(age_deg$fc_deg[,2]) & !is.na(age_deg$fc_deg[,3]),c(2,3)]
#heatmap.2(fc, Colv = NA, scale="column", cexCol=0.5, symbreaks=T)
rep = get_repartition(fc)
colnames(rep) = c("104w > 8w & 104w > 52w", "104w > 8w & 104w < 52w", "104w < 8w & 104w > 52w", "104w < 8w & 104w < 52w")
rep
With abs(FC) > 1
# 52w == 8w and 104w != 8w and 104w != 52w with abs(FC) > 1
genes = names((sort(age_deg$fc_deg[which(is.na(age_deg$fc_deg[,1]) & abs(age_deg$fc_deg[,2])>0 & abs(age_deg$fc_deg[,3])>0),2])))
plot_count_heatmap(genes,samples, annot)
# Genes that are differentially expressed in 52W vs 8W, in 104W vs 8W and in 104W vs 52W
fc = age_deg$fc_deg[!is.na(age_deg$fc_deg[,1]) & !is.na(age_deg$fc_deg[,2]) & !is.na(age_deg$fc_deg[,3]),c(1,2,3)]
#heatmap.2(fc, Colv = NA, scale="column", cexCol=0.5, symbreaks=T)
rep = get_repartition_3col(fc)
colnames(rep) = c(
"52w > 8w & 104w > 8w & 104w > 52w",
"52w > 8w & 104w > 8w & 104w < 52w",
"52w > 8w & 104w < 8w & 104w > 52w",
"52w > 8w & 104w < 8w & 104w < 52w",
"52w < 8w & 104w > 8w & 104w > 52w",
"52w < 8w & 104w > 8w & 104w < 52w",
"52w < 8w & 104w < 8w & 104w > 52w",
"52w < 8w & 104w < 8w & 104w < 52w")
rep
With abs(FC) > 1
# 52w != 8w and 104w != 8w and 104w != 52w with abs(FC) > 1
genes = names((sort(age_deg$fc_deg[which(abs(age_deg$fc_deg[,1])>0 & abs(age_deg$fc_deg[,2])>0 & abs(age_deg$fc_deg[,3])>0),1])))
plot_count_heatmap(genes,samples, annot)
Order: 52w VS 8w, 104w VS 52w, 104w VS 8w
par(mfrow=c(3,1),mar=c(0,0,0,0))
col_52w_vs_8w = get_deg_colors(age_deg, "52w VS 8w", connected_gene_colors, module_nb)
plot_net_with_layout(net, col_52w_vs_8w, pal2, layout, add_legend = FALSE)
col_104w_vs_52w = get_deg_colors(age_deg, "104w VS 52w", connected_gene_colors, module_nb)
plot_net_with_layout(net, col_104w_vs_52w, pal2, layout, add_legend = FALSE)
col_104w_vs_8w = get_deg_colors(age_deg, "104w VS 8w", connected_gene_colors, module_nb)
plot_net_with_layout(net, col_104w_vs_8w, pal2, layout, add_legend = FALSE)
full_go_desc = age_deg$GO_wall[[1]][,"term"]
names(full_go_desc) = age_deg$GO_wall[[1]][,"category"]
Dot-plot with the most over-represented GO (20 most significant p-values for the different comparison)
plot_top_go(age_deg$over_represented_GO,
age_deg$GO_wall,
"BP",
c("52w VS 8w", "104w VS 8w", "104w VS 52w"),
20)
Network based on description similarity
BP_network = create_GO_network(age_deg, "BP", BP_GO)
par(mfrow=c(3,1),mar=c(0,0,0,0))
plot_GO_networks(BP_network, "52w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 52w", full_go_desc, plot_interactive = FALSE)
52w VS 8w
# 52w VS 8w
plot_GO_networks(BP_network, "52w VS 8w", full_go_desc, plot_non_interactive = FALSE)
104w VS 52w
# 104w VS 52w
plot_GO_networks(BP_network, "104w VS 52w", full_go_desc, plot_non_interactive = FALSE)
104w VS 8w
# 104w VS 8w
plot_GO_networks(BP_network, "104w VS 8w", full_go_desc, plot_non_interactive = FALSE)
Dot-plot with the most over-represented GO (20 most significant p-values for the different comparison)
plot_top_go(age_deg$over_represented_GO,
age_deg$GO_wall,
"CC",
c("52w VS 8w", "104w VS 8w", "104w VS 52w"),
20)
CC_network = create_GO_network(age_deg, "CC", CC_GO)
par(mfrow=c(3,1),mar=c(0,0,0,0))
plot_GO_networks(CC_network, "52w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(CC_network, "104w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(CC_network, "104w VS 52w", full_go_desc, plot_interactive = FALSE)
Dot-plot with the most over-represented GO (20 most significant p-values for the different comparison)
plot_top_go(age_deg$over_represented_GO,
age_deg$GO_wall,
"MF",
c("52w VS 8w", "104w VS 8w", "104w VS 52w"),
20)
MF_network = create_GO_network(age_deg, "MF", MF_GO)
par(mfrow=c(3,1),mar=c(0,0,0,0))
plot_GO_networks(MF_network, "52w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(MF_network, "104w VS 8w", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(MF_network, "104w VS 52w", full_go_desc, plot_interactive = FALSE)
plot_kegg_pathways(age_deg$over_represented_KEGG[,"category"],
age_deg$fc_deg,
"../results/dge/age-effect/age/over_repr_kegg/")
Pathway graphs available at ../results/dge/age-effect/age/over_repr_kegg/
plot_kegg_pathways(age_deg$under_represented_KEGG[,"category"],
age_deg$fc_deg,
"../results/dge/age-effect/age/under_repr_kegg/")
Pathway graphs available at ../results/dge/age-effect/age/under_repr_kegg/